var _ = require("lodash");
// _.dropRightWhile(array, [predicate=_.identity])
// 创建一个切片数组，去除array中从 predicate 返回假值开始到尾部的部分
// 适合于数据排列非常规矩的情形，比如这里加上了 { user: "fred2", active: true },
// 返回值就会从最后一次不符合算起，并不会考虑前面的结果
// 从数组的末尾开始移除连续满足指定条件的元素，直到遇到第一个不满足该条件的元素为止
var users = [
  { user: "barney", active: true },
  { user: "fred", active: false },
  // { user: "fred2", active: true },
  { user: "pebbles", active: true },
];

let a = _.dropRightWhile(users, function (o) {
  return !o.active;
});
// console.log(a);

let b = _.dropRightWhile(users, { user: "pebbles", active: false });
// console.log(b);

let c = _.dropRightWhile(users, ["active", true]);
// console.log(c);

let d = _.dropRightWhile(users, "active");
console.log(d);
